

module.exports = function($scope, $state, $stateParams,$resource,$modal,item,itemparam,$modalInstance){

   $scope.user={};
   console.log(itemparam);
    $scope.user=itemparam;
    if(itemparam.type==1){
       itemparam.typename='景区';
    }
    if(itemparam.type==2){
       itemparam.typename='酒店';
    }
      if(itemparam.type==3){
       itemparam.typename='市旅游委';
    }
    if(itemparam.type==4){
       itemparam.typename='区县旅游局';
    }


    if(itemparam.place==0){
       itemparam.place='和平区';
    }
    if(itemparam.place==1){
       itemparam.place='沈河区';
    }
    if(itemparam.place==2){
       itemparam.place='皇姑区';
    }
      if(itemparam.place==3){
       itemparam.place='铁西区';
    }
    if(itemparam.place==4){
       itemparam.place='大东区';
    }
    if(itemparam.place==5){
       itemparam.place='东陵区';
    }
    if(itemparam.place==6){
       itemparam.place='于洪区';
    }
      if(itemparam.place==7){
       itemparam.place='苏家屯区';
    }
    if(itemparam.place==8){
       itemparam.place='沈北新区';
    }
    if(itemparam.place==9){
       itemparam.place='浑南新区';
    }
    if(itemparam.place==10){
       itemparam.place='辽中县';
    }
    if(itemparam.place==11){
       itemparam.place='康平县';
    }
      if(itemparam.place==12){
       itemparam.place='法库县';
    }
    if(itemparam.place==13){
       itemparam.place='新民市';
    }
    $scope.guanbi=function(){
    	 $modalInstance.dismiss('cancel');
        // $state.go('app.equipmentUserManage',{},{reload: true});
    }


   $scope.obj = {};
    $scope.objs = [];
    var idobj = {};

     $scope.maxSize = 5;            //最多显示多少个按钮
    $scope.bigCurrentPage = 1;      //当前页码
    $scope.itemsPerPage = 200000;         //每页显示几条
    var para = {
            pageNo:$scope.bigCurrentPage, 
            pageSize:$scope.itemsPerPage,
            'company.id' : item.id
        };
    $resource('/a/sys/user/ajaxlist', {}, {}).
      get(para, function(res){ 
    
            if(res.list.length!==0 || res.list!==''){
                for(var i=0;i<res.list.length;i++){
                      if(res.list[i].loginName==item.code){
                           
                              item.id=res.list[i].id;
                                       
                                 $resource('/a/sys/user/ajaxform', {'id':item.id}, {}).get({}, {}, function(res){
                                    
                                        $scope.objs = res.allRoles;
                                       
                                          $scope.obj = res.user;
                                            $scope.kk=res.user.roleNames.split(',');
                                            
                                            $scope.getroles= $scope.kk;

                                            $scope.obj.oldLoginName = $scope.obj.loginName;
                                            $scope.obj.roleIdList = [];
                                            $scope.obj['company.id'] = res.company.id;
                                            $scope.obj['office.id'] = res.office.id; 


                                            //角色选择
                                            for(var i = 0; i < $scope.objs.length; i++)
                                            {
                                                var tmp = $scope.objs[i];
                                                tmp.iselected = 0;
                                                for(var j = 0; j < res.roleIdList.length; j++)
                                                {
                                                    if(res.roleIdList[j] == tmp.id)
                                                    {
                                                        tmp.iselected = 1;
                                                        idobj[tmp.id] = '';
                                                        break;
                                                    }
                                                }

                                            }


                                })
                      }
                }
            }
      })

}